package com.chzc.config;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * sa-token注册拦截器,注解式鉴权
 * @author cv大魔王
 * @version 1.0
 * @date 2021/5/24 16:09
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截器，并排除登录接口地址
        registry.addInterceptor(new SaRouteInterceptor()).addPathPatterns("/pri/**").excludePathPatterns("/pri/user/login/**");
        // 开启注解式鉴权
        registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
    }


}
